package com.base;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: sun.hongliang
 * @create: 2019/10/31 17:15
 */
public class MapTest {
    public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();
        map.put("a","A");
        map.put("b","B");
        String v = map.computeIfAbsent("b",k->{
            System.out.println("bbbb");
            return "b";
        });  // 输出 B
        System.out.println(v);
        String v1 = map.computeIfAbsent("c",k->"v"); // 输出 v
        System.out.println(v1);
        System.out.println(map);
    }
}
